﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Model;
using Controller;

namespace Facade.Validator
{
    public class KPIValidator
    {
        public string ValidateOnSave(KPI KPIs)
        {
            string msg = "OK";
            if (KPIs.Description.Trim().Length <= 0)
                msg = "Please Enter KPI Description";
            if (KPIs.GroupKPI == null)
                msg = "Please Enter Group KPI";
            if (KPIs.CategoryKPI == null)
                msg = "Please Enter Category KPI";
            if (KPIs.TypeKPI == null)
                msg = "Please Enter Type KPI";
            if (KPIs.SubTypeKPI == null)
                msg = "Please Enter Sub Type KPI";
            if (KPIs.UoM == null)
                msg = "Please Enter UoM KPI";
            if (KPIs.UoMDetailMax == null)
                msg = "Please Enter UoM Detail KPI Max";
            if (KPIs.UoMDetailMin == null)
                msg = "Please Enter UoM Detail KPI Min";
            if (KPIs.Year == 0)
                msg = "Please Enter KPI Year";
            if (KPIs.Weight == 0)
                msg = "Please Enter KPI Weight";
            return msg;
        }

        public string ValidateOnUpdate(KPI KPIs)
        {
            string msg = "OK";
            if (KPIs.Description.Trim().Length <= 0)
                msg = "Please Enter KPI Description";
            if (KPIs.GroupKPI == null)
                msg = "Please Enter Group KPI";
            if (KPIs.CategoryKPI == null)
                msg = "Please Enter Category KPI";
            if (KPIs.TypeKPI == null)
                msg = "Please Enter Type KPI";
            if (KPIs.SubTypeKPI == null)
                msg = "Please Enter Sub Type KPI";
            if (KPIs.UoM == null)
                msg = "Please Enter UoM KPI";
            if (KPIs.UoMDetailMax == null)
                msg = "Please Enter UoM Detail KPI Max";
            if (KPIs.UoMDetailMin == null)
                msg = "Please Enter UoM Detail KPI Min";
            if (KPIs.Year == 0)
                msg = "Please Enter KPI Year";
            if (KPIs.Weight == 0)
                msg = "Please Enter KPI Weight";
            return msg;
        }


        public string ValidateKPIParentAndChildAssignment(Employee AssignTo, KPI KPIs)
        {
            KPIController cont = new KPIController();
            string msg = "OK";
            if (cont.ValidateKPIParentAndChildAssignment(AssignTo, KPIs))
                msg = "Invalid KPI Assignment: KPI Parent has been assigned to this employee";
            return msg;
        }
    }
}